<?php
class user_authenticate extends ti_interface
{
	function __construct()
	{
		$this->init(__FILE__);
	}
	
	function show_form()
	{
		global $ti;
		$this->swap_phrase('title','form title');
		$this->swap_block('center','login');		;
	}
	
	function process_form()
	{
		global $ti;
		$this->data['password'] = md5(md5($this->data['password']));
		#echo($this->query('update user'));
		$user = $this->query_row('check login','first_name');
		if($user)
		{
			foreach($user as $key=>$value)
			{
				$ti->session[$key] = $value;
			}
			ti::redirect('user/profile/show');
		}
		else
		{
			exit('user not found');
		}
	}
	
	function logout()
	{
		session_destroy();
		ti::redirect('user/authenticate/show_form');
	}
}
?>